package core.cards.election.gui;

import java.util.HashMap;
import java.util.Map;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Text;
import org.eclipse.wb.swt.SWTResourceManager;

import core.cards.CardResultFrontend;
import core.cards.election.model.VotingCard;
import core.cards.election.model.VotingCardOption;

public class CmpElectionResult extends CardResultFrontend {
	private Text txtResult;
	
	private Map<String, TbTmType> votingCardMap;

	CmpElectionResult(Composite parent) {
		super(parent, SWT.NONE);
		
		votingCardMap = new HashMap<String, TbTmType>();
		
		setLayout(new GridLayout(1, false));
		
		TabFolder tbFldrTypes = new TabFolder(this, SWT.NONE);
		tbFldrTypes.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		
		TabItem tbTmGeneral1 = new TabItem(tbFldrTypes, SWT.NONE);
		tbTmGeneral1.setText("General");
		
		TabFolder tbFldrCards = new TabFolder(tbFldrTypes, SWT.NONE);
		tbTmGeneral1.setControl(tbFldrCards);
		
		TabItem tbTmCard1 = new TabItem(tbFldrCards, SWT.NONE);
		tbTmCard1.setText("Card 1");
		
		Composite cmpResult = new Composite(tbFldrCards, SWT.NONE);
		tbTmCard1.setControl(cmpResult);
		cmpResult.setLayout(new GridLayout(1, false));
		
		txtResult = new Text(cmpResult, SWT.BORDER | SWT.MULTI);
		txtResult.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		txtResult.setEditable(false);
		txtResult.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		
		TabItem tbTmCard2 = new TabItem(tbFldrCards, SWT.NONE);
		tbTmCard2.setText("Card 2");
		
		TabItem tbTmRkw1 = new TabItem(tbFldrTypes, 0);
		tbTmRkw1.setText("RKW 1");
		// TODO Auto-generated constructor stub
	}
	
	class TbTmType extends TabItem {
		public TbTmType(TabFolder parent, int style) {
			super(parent, style);
			// TODO Auto-generated constructor stub
		}

		@Override
		protected void checkSubclass() {
			// Disable the check that prevents subclassing of SWT components
		}
	}
	
	class TbTmVotingCard extends TabItem {
		Map<String, Integer> voteCountMap;
		
		public TbTmVotingCard(TabFolder parent, VotingCard votingCard) {
			super(parent, SWT.NONE);
			
			voteCountMap = new HashMap<String, Integer>();
			for(VotingCardOption votingCardOption : votingCard.getVotingCardOptionList()) {
				voteCountMap.put(votingCardOption.getName(), 0);
			}
		}
		
		@Override
		protected void checkSubclass() {
			// Disable the check that prevents subclassing of SWT components
		}
	}
}
